package com.deyuanyun.pic.ctrl.validatefun;

import com.deyuanyun.pic.common.validator.vinterface.ValidateInterface;
import org.apache.commons.beanutils.BeanUtils;

import java.lang.reflect.InvocationTargetException;

/**
 * 模块描述
 *
 * @author scalpel.王敏
 * @version [v1.0] 创建时间（2016/9/22）
 * @see // 引用的类
 * Method List:
 * 1.----------------
 * 2.----------------
 * History:
 */
public class DeviceValeRoomVali implements ValidateInterface {

    @Override
    public <T, E, C> boolean apply(T t, E e, C c) throws NoSuchFieldException {
        String val= (String) t;
        if(val != null && !"".equals(val))
        {
            String vals[]=val.split("_\\$_");
            try {
                BeanUtils.setProperty(c,"pipeValveroomId",vals[1]);
                if(!vals[0].equals(vals[1]))
                {
                    BeanUtils.setProperty(c,"pipeValveroomId",vals[2]);
                    return false;
                }
                return true;
            } catch (IllegalAccessException e1) {
                e1.printStackTrace();
            } catch (InvocationTargetException e1) {
                e1.printStackTrace();
            }


        }
        return true;
    }

    @Override
    public String getName() {
        return null;
    }
}
